<?php

namespace backend\modules\android_app_versions\models;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\android_app_versions\models\AndroidAppVersions;

/**
 * AndroidAppVersionsSearch represents the model behind the search form about `backend\modules\android_app_versions\models\AndroidAppVersions`.
 */
class AndroidAppVersionsSearch extends AndroidAppVersions
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'status', 'is_credit', 'is_evaluate', 'is_doing_order', 'is_query_customer_info', 'is_fave_verify', 'is_sign_information'], 'integer'],
            [['v_number', 'v_title', 'face_mode', 'update_db', 'update_db_path', 'v_content', 'interview', 'other_download_u_ids', 'black_user_list', 'white_version_list', 'app_download_url'], 'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = AndroidAppVersions::find();

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        $query->andFilterWhere([
            'id' => $this->id,
            'status' => $this->status,
            'is_credit' => $this->is_credit,
            'is_evaluate' => $this->is_evaluate,
            'is_doing_order' => $this->is_doing_order,
            'is_query_customer_info' => $this->is_query_customer_info,
            'is_fave_verify' => $this->is_fave_verify,
            'is_sign_information' => $this->is_sign_information,
        ]);

        $query->andFilterWhere(['like', 'v_number', $this->v_number])
            ->andFilterWhere(['like', 'v_title', $this->v_title])
            ->andFilterWhere(['like', 'face_mode', $this->face_mode])
            ->andFilterWhere(['like', 'update_db', $this->update_db])
            ->andFilterWhere(['like', 'update_db_path', $this->update_db_path])
            ->andFilterWhere(['like', 'v_content', $this->v_content])
            ->andFilterWhere(['like', 'interview', $this->interview])
            ->andFilterWhere(['like', 'other_download_u_ids', $this->other_download_u_ids])
            ->andFilterWhere(['like', 'black_user_list', $this->black_user_list])
            ->andFilterWhere(['like', 'white_version_list', $this->white_version_list])
            ->andFilterWhere(['like', 'app_download_url', $this->app_download_url]);

        return $dataProvider;
    }
}
